package cn.jbolt.ai.klb.entity;

import cn.jbolt.ai.klb.FileState;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.jboltai.resource.ai.AIModel;
import io.swagger.v3.oas.annotations.media.Schema;

import java.io.Serializable;
import java.util.Date;

@TableName("ja_ai_file")
public class AiFile implements Serializable {

    @TableField(exist = false)
    public final static String RESOURCES_QINIU = "qiniu"; //七牛
    @TableField(exist = false)
    public final static String RESOURCES_LOCAL = "local"; //本地


    private static final long serialVersionUID = 1L;

    @TableId(type = IdType.ASSIGN_ID)
    private Long id;

    @Schema(name = "knowledgeBaseId", description = "知识库ID")
    @TableField("knowledge_base_id")
    private Long knowledgeBaseId;

    @Schema(name = "filePath", description = "文件地址")
    @TableField("file_path")
    private String filePath;

    @Schema(name = "fileName", description = "文件名称")
    @TableField("file_name")
    private String fileName;

    @Schema(name = "fileSize", description = "文件大小")
    @TableField("file_size")
    private Long fileSize;


    @Schema(name = "fileType", description = "文件类型,例如:txt,excel,pdf等")
    @TableField("file_type")
    private String fileType;

    @Schema(name = "docType", description = "文件类型,例如:normal:普通文档,QA:QA文档")
    @TableField("doc_type")
    private String docType;

    @Schema(name = "fileStatus", description = "文件状态,100:普通文档未拆分,QA文档未训练," +
            "200:普通文档拆分中,QA文档训练中,300:普通文档拆分成功,QA文档训练成功," +
            "400:普通文档拆分失败,QA文档训练失败,500:向量化中,600:向量化成功,700:向量化失败")
    @TableField("file_status")
    private Integer fileStatus;


    @Schema(name = "trainingTime", description = "训练时间")
    @TableField("training_time")
    @JsonFormat(locale = "zh", pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date trainingTime;

    @Schema(name = "embedTime", description = "向量化时间")
    @JsonFormat(locale = "zh", pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField("embed_time")
    private Date embedTime;

    @Schema(name = "splitRule", description = "拆分规则,是一个json")
    @TableField("split_rule")
    private String splitRule;


    @Schema(name = "createTime", description = "创建时间")
    @JsonFormat(locale = "zh", pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private Date createTime;

    //非数据库字段
    @TableField(exist = false)
    private String fileStatuesName;


    @TableField(exist = false)
    private String aiKnowledgeBaseName;

    //分块大小
    @TableField(exist = false)
    private Integer chunkSize;

    //重叠数
    @TableField(exist = false)
    private Integer chunkOverlap;

    //模型
    @TableField(exist = false)
    private AIModel aiModel;

    //默认模型
    @TableField(exist = false)
    private String defaultModel;

    //是否提取资源
    @TableField(exist = false)
    private Boolean extractResources;

    //存储位置 local-本地 qiniu-七牛
    @TableField(exist = false)
    private String resourcesPosition;

    //存储地址
    @TableField(exist = false)
    private String path;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getKnowledgeBaseId() {
        return knowledgeBaseId;
    }

    public void setKnowledgeBaseId(Long knowledgeBaseId) {
        this.knowledgeBaseId = knowledgeBaseId;
    }

    public String getFilePath() {
        return filePath;
    }

    public void setFilePath(String filePath) {
        this.filePath = filePath;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public Long getFileSize() {
        return fileSize;
    }

    public void setFileSize(Long fileSize) {
        this.fileSize = fileSize;
    }

    public String getFileType() {
        return fileType;
    }

    public void setFileType(String fileType) {
        this.fileType = fileType;
    }

    public Integer getFileStatus() {
        return fileStatus;
    }

    public void setFileStatus(Integer fileStatus) {
        this.fileStatus = fileStatus;
    }


    public String getSplitRule() {
        return splitRule;
    }

    public void setSplitRule(String splitRule) {
        this.splitRule = splitRule;
    }


    public String getFileStatuesName() {
        return FileState.getByCode(getFileStatus()).getDescription();
    }

    public void setFileStatuesName(String fileStatuesName) {
        this.fileStatuesName = fileStatuesName;
    }

    public String getAiKnowledgeBaseName() {
        return aiKnowledgeBaseName;
    }

    public void setAiKnowledgeBaseName(String aiKnowledgeBaseName) {
        this.aiKnowledgeBaseName = aiKnowledgeBaseName;
    }

    public Date getTrainingTime() {
        return trainingTime;
    }

    public void setTrainingTime(Date trainingTime) {
        this.trainingTime = trainingTime;
    }

    public Date getEmbedTime() {
        return embedTime;
    }

    public void setEmbedTime(Date embedTime) {
        this.embedTime = embedTime;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Integer getChunkSize() {
        return chunkSize;
    }

    public void setChunkSize(Integer chunkSize) {
        this.chunkSize = chunkSize;
    }

    public Integer getChunkOverlap() {
        return chunkOverlap;
    }

    public void setChunkOverlap(Integer chunkOverlap) {
        this.chunkOverlap = chunkOverlap;
    }

    public String getDocType() {
        return docType;
    }

    public void setDocType(String docType) {
        this.docType = docType;
    }

    public AIModel getAiModel() {
        return aiModel;
    }

    public void setAiModel(AIModel aiModel) {
        this.aiModel = aiModel;
    }

    public String getDefaultModel() {
        return defaultModel;
    }

    public void setDefaultModel(String defaultModel) {
        this.defaultModel = defaultModel;
    }

    public Boolean getExtractResources() {
        return extractResources;
    }

    public void setExtractResources(Boolean extractResources) {
        this.extractResources = extractResources;
    }

    public String getResourcesPosition() {
        return resourcesPosition;
    }

    public void setResourcesPosition(String resourcesPosition) {
        this.resourcesPosition = resourcesPosition;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }


}
